namespace LegoBotPrima.Actions
{
    public class WaitBotAction : BotAction
    {
        private static readonly object _synch_OnTimerTick = new object();

        public int Seconds { get; set; }
        public BotAction AfterWaitAction { get; set; }



        private int _tickNumber;
        public override void OnTimerTick(int tickNimber)
        {
            lock (_synch_OnTimerTick)
            {
                this._tickNumber++;

                if (this._tickNumber == (Seconds * 10))// 200 ms after the first call
                {
                    this.RequestedNextAction = this.AfterWaitAction ?? new StopBotAction();
                    Workflow.EndAction(this);
                }
            }
        }

        public override string ToString()
        {
            return base.ToString() + " Seconds:" + Seconds + " AfterWaitAction:" + AfterWaitAction;
        }
    }
}